<style lang="less">
    .mb20 {
        margin-bottom: 20px;
    }

</style>

<template>
    <div>
        <!--    <span style="margin-left: 60px">名字：</span> <Input v-model="name" placeholder="" style="width: 200px" />-->
        <!--    <span style="margin-left: 40px">身份证号：</span><Input v-model="cardno" placeholder="" style="width: 200px" />-->
        <!--   <span style="margin-left: 20px">补贴类型：<Select v-model="model1" style="width:200px">-->
        <!--        <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>-->
        <!--    </Select>-->
        <!--       </span>-->
        <!--    </div>-->
        <!--    <div style="margin-top: 10px">-->
        <!--    <span style="margin-left: 15px">发放起始时间：</span>  <DatePicker type="daterange" v-model="dateTime" placement="bottom-end" placeholder="" style="width: 200px"></DatePicker>-->
        <!--        <span style="margin-left: 15px">发放截止时间：</span>  <DatePicker type="daterange" v-model="dateTime1" placement="bottom-end" placeholder="" style="width: 200px"></DatePicker>-->
        <Row class="bench_search">
            <Col span="1" class="ivu-form-item-label" style="margin-top: 8px">区县：</Col>
            <Col span="4">
                <Select v-model="select1" transfer="" style="width: 70%;">
                    <Option :value="JSON.stringify(item)" v-for="item in mailList" v-bind:key="item.id">{{item.title}}</Option>
                </Select>
            </Col>
            <Col span="1" class="ivu-form-item-label" style="margin-top: 8px">街道：</Col>
            <Col span="4">
                <Select v-model="select2" transfer="" style="width: 70%;">
                    <Option :value="item.title" v-for="item in streetList" v-bind:key="item.id">{{item.title}}</Option>
                </Select>
            </Col>
            <Col span="2" class="ivu-form-item-label" style="margin-top: 8px">补贴类型：</Col>
            <Col span="4">
                <Select v-model="searchInfo.subsidy_type" transfer="" style="width: 70%;">
                    <Option value="重度残疾人护理补贴">重度残疾人护理补贴</Option>
                    <Option value="困难残疾人生活补贴">困难残疾人生活补贴</Option>
                </Select>
            </Col>
            <Col span="2">
                <Button type="info" @click="search()"><Icon type="ios-search" /> 核查</Button>
            </Col>
        </Row>
        <!--        <Button type="primary" style="margin-left: 80px"  @click="findlist()"><Icon type="ios-search" />搜索</Button>-->
        <div style="margin-top: 20px">
            <Table border :columns="columns1" :data="data6">
                <template slot-scope="{ row }" slot="action">
                    <Button type="info" size="small"  @click="findinfo(row)">查看详情</Button>
                    <Button  v-if="row.state==='2'||row.state==='4'||row.state==='0'" style="margin-left: 5px" type="error" size="small" @click="stop(row)">停发</Button>
                    <Button  v-if="row.state==='1'" style="margin-left: 5px" type="warning" size="small" @click="paymentafterwards(row)">追缴</Button>
                    <Button  v-if="row.state==='1'" style="margin-left: 5px" type="success" size="small" @click="renewalcollar(row)">续领</Button>
                </template>
            </Table>
        </div>
        <!--        <div style="margin-top: 20px;text-align: right">-->
        <!--            <Page :total="totla" show-total :page-size="pagesize" :current="pageno" />-->
        <!--        </div>-->
        <div  class="page" style="margin-top: 20px;text-align: right">
            <Page :total="totalnum" :current="currentpageNo" :page-size="currentpageSize" @on-change="change" class="page_style"/>
        </div>
        <Modal
                v-model="show1"
                title="详细信息"
                @on-ok="ok1()"
                @on-cancel="show1===false" width="800">
            <Form label-position="right" :label-width="100" style="position: relative;">
                <Row class="mb20">
                    <Col span="16" class="ivu-form-item-label" style="font-size: 20px">辽宁省残疾人两项补贴情况表</Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">姓名：</Col>
                    <Col span="5" class="ivu-form-item-content"><Input v-model="mainmap.name" ></Input></Col>
                    <Col span="6" class="ivu-form-item-label">性别：</Col>
                    <Col span="5" class="ivu-form-item-content"><Input v-model="mainmap.sex" ></Input></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">出生日期：</Col>
                    <Col span="5"><Input v-model="mainmap.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">民族：</Col>
                    <Col span="5"><Input v-model="mainmap.nation" style="width: 150px"  /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">身份证号码：</Col>
                    <Col span="5"><Input v-model="mainmap.cardno" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">残疾证号码：</Col>
                    <Col span="5"><Input v-model="mainmap.disability_certificate_number" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">残疾类别：</Col>
                    <Col span="5"><Input v-model="mainmap.disability_type" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">残疾等级：</Col>
                    <Col span="5"><Input v-model="mainmap.disability_grade" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">户籍性质：</Col>
                    <Col span="5"><Input v-model="mainmap.household" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">户籍地址：</Col>
                    <Col span="5"><Input v-model="mainmap.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">残疾人电话：</Col>
                    <Col span="5"><Input v-model="mainmap.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">家庭住址：</Col>
                    <Col span="5"><Input v-model="mainmap.homeaddress" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">联系人：</Col>
                    <Col span="5"><Input v-model="mainmap.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">联系人电话：</Col>
                    <Col span="5"><Input v-model="mainmap.link_phone" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">补贴对象类型：</Col>
                    <Col span="5"><Input v-model="mainmap.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">补贴类型：</Col>
                    <Col span="5"><Input v-model="mainmap.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">补贴金额：</Col>
                    <Col span="5"><Input v-model="map1.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">发放起始月份：</Col>
                    <Col span="5"><Input v-model="map1.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">开户银行：</Col>
                    <Col span="5"><Input v-model="map1.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">银行卡号：</Col>
                    <Col span="5"><Input v-model="map1.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">账户名：</Col>
                    <Col span="5"><Input v-model="map1.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">低保类型：</Col>
                    <Col span="5"><Input v-model="map1.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">发证时间：</Col>
                    <Col span="5"><Input v-model="map1.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">注销时间：</Col>
                    <Col span="5"><Input v-model="map1.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">所属县区：</Col>
                    <Col span="5"><Input v-model="map1.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">所属乡镇：</Col>
                    <Col span="5"><Input v-model="map1.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="3" class="ivu-form-item-label">两补申请状态：</Col>
                    <Col span="5"><Input v-model="map1.name" style="width: 150px"/></Col>
                    <Col span="6" class="ivu-form-item-label">两补停发状态：</Col>
                    <Col span="5"><Input v-model="map1.sex" style="width: 150px" /></Col>
                </Row>
                <Row class="mb20">
                    <Col span="10" class="ivu-form-item-label">现补贴情况</Col>
                </Row>
                <Row class="mb20">
                    <Table border :columns="columns1" :data="presentSubsidyData">
                    </Table>
                </Row>
                <Row class="mb20">
                    <Col span="10" class="ivu-form-item-label">历史补贴情况</Col>
                </Row>
                <Row class="mb20">
                    <Col span="10" class="ivu-form-item-label">补发情况</Col>
                </Row>
                <Row class="mb20">
                    <Col span="10" class="ivu-form-item-label">追缴情况</Col>
                </Row>
                <Row class="mb20">
                    <Col span="10" class="ivu-form-item-label">补贴享受过程</Col>
                </Row>
            </Form>
        </Modal>
    </div>
</template>
<script>
import { findAllGrantUserList, date2str, updateStateByIdToStop, RenewalCollar, PaymentAfterwards, findAllCityList, findAllInfo, getUserInfo } from '@/api/stree'

export default {
  data () {
    return {
      mainmap: {},
      infolist: [],
      sotinglist: [],
      usermap: {},
      checkList: [],
      warningStr: '',
      select1: '',
      select2: '',
      map1: { name: '', cardno: '', sex: '' },
      show1: false,
      name: '',
      cardno: '',
      model1: '',
      pageSize: 10,
      pageNo: 1,
      totalnum: 0,
      currentpageNo: 1,
      currentpageSize: 10,
      searchInfo: {},
      mailList: [],
      streetList: [],
      dateTime: [],
      dateTime1: [],
      cityList: [
        {
          value: '生活补贴',
          label: '生活补贴'
        },
        {
          value: '护理补贴',
          label: '护理补贴'
        }],
      columns1: [
        {
          title: '姓名',
          key: 'name',
          width: 150,
          align: 'center'
        },
        {
          title: '电话号码',
          width: 200,
          key: 'cardno'
        },
        {
          title: '身份证号',
          width: 200,
          key: 'subsidy_person_type'
        },
        {
          title: '事项名称',
          width: 150,
          key: 'subsidy_type'
        },
        {
          title: '事项名称',
          width: 150,
          key: 'subsidy_type'
        },
        {
          title: '事项名称',
          width: 150,
          key: 'subsidy_type'
        },
        {
          title: '操作',
          slot: 'action',
          width: 150,
          align: 'center'
        }
      ],
      data6: [],
      presentSubsidyData: []
    }
  },
  computed: {

  },
  methods: {
    findinfo (param) { // 查看详情
      this.show1 = true
      getUserInfo({ 'id': param.id }).then(ret => {
        if (ret.data.errcode === 0) {
          this.mainmap = ret.data.data.mainmap
          console.log(this.mainmap)
        } else {
          this.$Modal.error({
            title: '错误',
            content: ret.data.errmsg
          })
        }
      })
    },
    paymentafterwards (param) {
      let id = param.id
      let data2 = { 'id': id }
      if (confirm('确定追缴吗')) {
        PaymentAfterwards(data2).then(ret => {
          if (ret.data.errcode === 0) {
            this.init()
          } else {
            this.$Modal.error({
              title: '错误',
              content: ret.data.errmsg
            })
          }
        })
      }
    },
    renewalcollar (param) {
      let id = param.id
      let data2 = { 'id': id }
      if (confirm('确定续领吗')) {
        RenewalCollar(data2).then(ret => {
          if (ret.data.errcode === 0) {
            this.init()
          } else {
            this.$Modal.error({
              title: '错误',
              content: ret.data.errmsg
            })
          }
        })
      }
    },
    stop (param) {
      let id = param.id
      let data2 = { 'id': id }
      if (confirm('确定停发吗')) {
        updateStateByIdToStop(data2).then(ret => {
          if (ret.data.errcode === 0) {
            this.init()
          } else {
            this.$Modal.error({
              title: '错误',
              content: ret.data.errmsg
            })
          }
        })
      }
    },
    findlist () {
      console.log('名字：' + this.name)
      console.log('身份证：' + this.cardno)
      console.log('类型：' + this.model1)
      console.log('时间：' + this.dateTime)
      let state_time = date2str(this.dateTime[0])
      let end_time = date2str(this.dateTime[1])
      let state_time1 = date2str(this.dateTime1[0])
      let end_time1 = date2str(this.dateTime1[1])
      let data1 = {
        'name': this.name,
        'cardno': this.cardno,
        'subsidy_type': this.model1,
        'state_time': state_time,
        'end_time': end_time,
        'state_time1': state_time1,
        'end_time1': end_time1,
        'pageNo': this.pageNo,
        'pageSize': this.pageSize
      }
      findAllGrantUserList(data1).then(ret => {
        console.log('111111111111' + ret)
        if (ret.data.errcode === 0) {
          this.data6 = ret.data.data.results
          this.totalnum = ret.data.data.totalRecord
        } else {
          this.$Modal.error({
            title: '错误',
            content: ret.data.errmsg
          })
        }
      })
    },
    init () {
      let param = {
        pageSize: this.currentPageSize,
        pageNo: this.currentPageNo
      }
      findAllGrantUserList(param).then(ret => {
        console.log(ret)
        if (ret.data.errcode === 0) {
          this.data6 = ret.data.data.results
          this.totalnum = ret.data.data.totalRecord
          this.data6.forEach((item) => {
            if (item.state === '0') {
              item['addstate'] = '发放中'
            } else if (item.state === '1') {
              item['addstate'] = '已停发'
            } else if (item.state === '2') {
              item['addstate'] = '已续领'
            } else if (item.state === '3') {
              item['addstate'] = '续领审核中'
            } else if (item.state === '4') {
              item['addstate'] = '已追缴'
            } else if (item.state === '5') {
              item['addstate'] = '追缴审核中'
            }
          })
        } else {
          this.$Modal.error({
            title: '错误',
            content: ret.data.errmsg
          })
        }
      })
    },
    getMailList () {
      findAllCityList().then(ret => {
        console.log(ret)
        if (ret.data.errcode === 0) {
          this.mailList = ret.data.data
        } else {
          this.$Modal.error({
            title: '错误',
            content: ret.data.errmsg
          })
        }
      })
    },
    search () {
      findAllInfo(this.searchInfo).then(ret => {
        console.log(ret)
        if (ret.data.errcode === 0) {
          this.data6 = ret.data.data.results
          this.checkList = ret.data.data.results
          this.totalnum = ret.data.data.totalRecord
          for (var i = 0; i < this.checkList.length; i++) {
            console.log(this.checkList[i].allowancesmap.data.type, '111')
            if (this.checkList[i].subsidy_person_type === '困难残疾人生活补贴') {
              if (this.checkList[i].allowancesmap.errcode === '0000') { // 核查低保
                if (this.checkList[i].allowancesmap.data.type === '9999') {
                  this.warningStr = this.warningStr + '非保障户'
                  console.log(this.warningStr)
                } else {
                  console.log('是保障户')
                }
              } else {
                console.log('接口报错,弹出信息')
              }
              if (this.checkList[i].registermap.result !== '0') { // 核查户籍
                this.warningStr = this.warningStr + '非沈阳户籍'
              } else {
                console.log('沈阳户籍')
              }
              if (this.checkList[i].deadmap.flag !== 'false') {
                this.warningStr = this.warningStr + '已登记死亡'
              } else {
                console.log('未登记死亡')
              }
              if (this.checkList[i].disabilitylist.length === 0) {
                this.warningStr = this.warningStr + '非残疾人'
              } else {
                console.log('残疾人')
              }
            } else if (this.checkList[i].subsidy_person_type === '重度残疾人护理补贴') {
              console.log('~~~~')
            }
            // var obj1 = JSON.parse(this.checkList[i].allowancesmap)
            // console.log(obj1)
          }
        } else {
          this.$Modal.error({
            title: '错误',
            content: ret.data.errmsg
          })
        }
      })
    },
    change (pageNo) {
      this.currentPageNo = pageNo
      this.currentPageSize = 10
      this.init()
    }
  },
  watch: {
    select1 (str) {
      var obj = JSON.parse(str)
      this.searchInfo.county = obj.title
      findAllCityList({ id: obj.id }).then(res => {
        this.streetList = res.data.data
        console.log(this.streetList)
      })
    },
    select2 (val) {
      this.searchInfo.township = val
    }
  },
  mounted () {
    this.init()
    this.getMailList()
  }
}
</script>
